package com.itheima.demo;

import java.util.Scanner;

/**
 * @author jiangxun
 * @date 11-13-2024
 */
public class AllTest {
    public static void main(String[] args) {
        // 目标：完成健康计算机
        Scanner sc = new Scanner(System.in);
        // 1 先让用户输入自己的个人信息：身高，体重，年龄，性别
        System.out.println("请输入您的身高（cm）：");
        double height = sc.nextDouble();
        System.out.println("请输入您的体重（kg）：");
        double weight = sc.nextDouble();
        System.out.println("请输入您的性别（男/女）：");
        String sex = sc.next();
        System.out.println("请输入您的年龄：");
        int age = sc.nextInt();

        // 2 计算BMI指数
        double bmi = calculateBMI(height, weight);
        System.out.println("您的BMI指数为：" + bmi);

        // 3 根据BMI指数，判断是否为肥胖
        double bmr = calculateBMR(height, weight,sex, age);
        System.out.println("您的基础代谢率为：" + bmr);
    }

    private static double calculateBMR(double height, double weight, String sex, int age) {
        double bmr=0;
        if("男".equals(sex)){
            bmr=88.362+ (13.397*weight)+ (4.799*height)- (5.677*age);
        }else{
            bmr=447.593+ (9.247*weight)+ (3.098*height)- (4.330*age);
        }
        return bmr;
    }

    private static double calculateBMI(double height, double weight) {
        return weight / (height / 100) / (height / 100);
    }
}
